//
//  PhotoSelectCell.m
//  SinaWeibo
//
//  Created by Apple on 16/8/17.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "PhotoSelectCell.h"



@interface PhotoSelectCell()

@property (weak, nonatomic) IBOutlet UIButton *addImgBtn;

@property (weak, nonatomic) IBOutlet UIButton *deleteImgBtn;

@end

@implementation PhotoSelectCell

- (IBAction)addImg:(UIButton *)sender {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:kAddImg object:nil];
    
}

- (IBAction)deleteImg:(UIButton *)sender {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:kDeleteImg object:self];

}

-(void)setCellImage:(UIImage *)cellImage{
    
    _cellImage = cellImage;
    
    if (_cellImage == nil) {
        
        self.addImgBtn.enabled = YES;
        
        self.deleteImgBtn.hidden = YES;
        
        //防止删除图片时出现缓存错误，要重新设置加号cell的图片和高亮图片
        [self.addImgBtn setBackgroundImage:[UIImage imageNamed:@"compose_pic_add"] forState:UIControlStateNormal];
        [self.addImgBtn setBackgroundImage:[UIImage imageNamed:@"compose_pic_add_highlighted"] forState:UIControlStateHighlighted];
        
    }else{
        
        [self.addImgBtn setBackgroundImage:_cellImage forState:UIControlStateDisabled];
        self.deleteImgBtn.hidden = NO;
        self.addImgBtn.enabled = NO;
        
    }



}



@end
